/* GSExcelToManufacture.java
 *
 * Project/Product: APEP-JZCG
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   peng.ning	2008-10-24	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2008
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package com.hitrust.gs.action;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

import org.apache.struts.upload.FormFile;

import system.base.ProductTypeManager;

import com.hitrust.gs.bean.GSManufactureCategoryBean;
import com.hitrust.gs.bean.GSProviderBean;
import com.hitrust.gs.business.GSManufactureCategoryProcessor;
import com.hitrust.gs.business.GSProviderProcessor;
import com.hitrust.gs.dao.GSProductBidDao;
import com.hitrust.gs.dao.GSProductTypeDao;
import com.hitrust.gs.form.GSImportExcelForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.RegulaUtil;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.lang.StringUtils;
import com.hitrust.gs.util.page.ResultProcess;
import com.hitrust.gs.vo.GSManufactureView;

import framework.core.Conditions;
import framework.core.DBConnection;
import framework.core.ObjectList;

public class GSExcelToManufacture extends GSBaseAction {

    /*
     * (non-Javadoc)
     * 
     * @see com.apep.jzcg.service.GSBaseAction#execute(com.apep.jzcg.service.GSBaseForm)
     */

    public static final String SHEET_NAME = "产品信息";
    public static final String SEP = "%";
    public static String[] HEAD_NAMES = { "序号", "种类编码", "集中编码", "产品名称", "供应商编码", "产品单价", "数量单位", "是否采购", "结算模式","产品使用分类","产品招标分类", "型号", "规格", "质保期", "生产厂商", "产地", "品牌", "图件号",
            "适用车型", "适用机型", "适用底盘", "级别特征", "材质", "其他属性", "备注","公里质保期","售价","产品分类","招标分类","是否到单车"};
    public static String[] HEAD_NAMES_PRICE = { "序号", "种类编码", "集中编码", "产品名称", "供应商编码", "产品单价", "计划价","数量单位", "是否采购", "型号", "规格", "质保期", "生产厂商", "产地", "品牌", "图件号",
        "适用车型", "适用机型", "适用底盘", "级别特征", "材质", "其他属性", "备注" };
    public boolean[] COL_CHECK = new boolean[30];
    public boolean[] COL_CHECK_PRICE = new boolean[23];
    public GSManufactureView manuview = null;
    GSProviderProcessor ppro = new GSProviderProcessor();
    
    //匹配不包括 ',",<,>,&的特殊字符
    public static final String regula = "[^'\"<>&]*";
    public static final String zhibao = "^\\d+$";
    
    GSManufactureCategoryProcessor mcpro = new GSManufactureCategoryProcessor();
    public String execute(GSBaseForm aForm) throws Exception {
        GSImportExcelForm tGSImportExcelForm = (GSImportExcelForm) aForm;
        FormFile formFile = tGSImportExcelForm.getExcelfile();
        tGSImportExcelForm.getRequest().setAttribute("target", "_self");
        Object modify = aForm.getSession().getAttribute("modify");
        if(modify!=null&&modify.toString().equals("true")){
            tGSImportExcelForm.getRequest().setAttribute("action", "A400412.do");
        }else
           tGSImportExcelForm.getRequest().setAttribute("action", "A400313.do");
        if (formFile!=null) {
            ArrayList tList = loadDataFromExcel(formFile.getInputStream());
            ResultProcess tProc = new ResultProcess();
            tProc.setResult(tList);
            if(GSBaseConstants.PLANPRICE.equals("true")){
                aForm.getRequest().setAttribute("isPlanprice", "1");
            }else{
                aForm.getRequest().setAttribute("isPlanprice", "0");
            }
            aForm.getSession().setAttribute("manufactureExcel", tProc);
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }

    /**
     * 从Excel中载入格式化数据，数据项之间以分隔符%隔开
     * 
     * @param aInputStream
     * @param aPage
     * @param aPageSize
     * @return
     * @throws Exception
     */
    public ArrayList loadDataFromExcel(InputStream aInputStream) throws Exception {

        ArrayList tPageDataList = new ArrayList();
        Workbook tExcelWorkbook = null;

        try {
            tExcelWorkbook = Workbook.getWorkbook(aInputStream);

            Sheet tExcelSheet = tExcelWorkbook.getSheet(SHEET_NAME);
            if (tExcelSheet == null) {
                throw new GSException("批量导入产品失败:文件格式不正确,无法找到：" + SHEET_NAME);
            }
            for (int i = 1; i < tExcelSheet.getRows(); i++) {
                Cell tCells[] = tExcelSheet.getRow(i);
                String tRowText = "";
                int num = tCells.length;
                for (short j = 0; j < num; j++) {
                    Cell tExcelCell = tCells[j];
                    if (tExcelCell == null) {
                        break;
                    }
                    String tCellValue = tExcelCell.getContents();
                    if (tCellValue.length() == 0) {
                        tCellValue = " ";
                    }
                    tRowText += tCellValue + SEP;
                }
                if(GSBaseConstants.PLANPRICE.equals("true")){
                    for (int a = num; a < HEAD_NAMES_PRICE.length; a++) {
                        tRowText += " " + SEP;
                    }
                }else{
                    for (int a = num; a < HEAD_NAMES.length; a++) {
                        tRowText += " " + SEP;
                    }
                }

                // 检查数据是否正确,如果和数据库中不符则将结果添加到末尾,从第二行开始
                
                if(GSBaseConstants.PLANPRICE.equals("true")){
                tRowText = this.checkManufacturePrice(tRowText,i-1);
                for (int tJ = 0; tJ < COL_CHECK_PRICE.length; tJ++) {
                    if (COL_CHECK_PRICE[tJ] == false) {
                        throw new GSException(tRowText);
                    }
                }
                }else{
                tRowText = this.checkManufacture(tRowText,i-1);
                for (int tJ = 0; tJ < COL_CHECK.length; tJ++) {
                    if (COL_CHECK[tJ] == false) {
                        throw new GSException(tRowText);
                    }
                }
                }

                tPageDataList.add(manuview);
                GSLogWriter.info(tRowText);
            }
        } catch (BiffException e) {
            GSLogWriter.error(e.getMessage());
            throw new GSException("批量导入产品明细失败:文件格式不正确！");
        } catch (IOException e) {
            GSLogWriter.error(e.getMessage());
            throw new GSException("批量导入产品明细失败:文件格式不正确！");
        } finally {
            if (tExcelWorkbook != null)
                tExcelWorkbook.close();
        }
        return tPageDataList;
    }

    /**
     * 检查产品明细数据是否正确，如不正确则在结果文本最后添加分析结果
     * 
     * @param aRowText
     * @return
     * @throws GSException
     */
     
    public String checkManufacturePrice(String aRowText,int a) throws GSException {
        manuview = new GSManufactureView();
        for (int i = 0; i < COL_CHECK_PRICE.length; i++) {
            COL_CHECK_PRICE[i] = true;
        }
        try {
            String[] tRecorderColumns = aRowText.split(SEP);
            for (int i = 0; i < tRecorderColumns.length; i++) {
            	if(!RegulaUtil.matchByString(tRecorderColumns[i],regula )){
            		 COL_CHECK[i] = false;
                     return HEAD_NAMES[0] + tRecorderColumns[i] + ": " + HEAD_NAMES[i] + "中不能有',\",<,>,&等特殊字符!";
            	}
			}
            manuview.setGs_manufacture_id(tRecorderColumns[0].trim());
            if ("".equals(tRecorderColumns[1].trim())) {
                COL_CHECK_PRICE[1] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[1] + "不能为空!";
            } else {
                    GSManufactureCategoryBean mcbean = mcpro.queryManufactureCatetoryByIdOrName(tRecorderColumns[1].trim());
                    if (mcbean == null) {
                        COL_CHECK_PRICE[1] = false;
                        return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[1] + "不存在或有相同类型名称！";
                    } else {
                        manuview.setGs_manufacture_category_id(mcbean.getGs_manufacture_category_id());
                        manuview.setGs_manufacture_category_name(mcbean.getGs_manufacture_category_name());
                    }            
            }
            if ("".equals(tRecorderColumns[2].trim())) {
                COL_CHECK_PRICE[2] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[2] + "不能为空!";
            } else {
                manuview.setGs_concentricity_id(tRecorderColumns[2].trim());
            }
            if ("".equals(tRecorderColumns[3].trim())) {
                COL_CHECK_PRICE[3] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[3] + "不能为空!";
            } else {
                manuview.setGs_manufacture_name(tRecorderColumns[3].trim());
            }
            if ("".equals(tRecorderColumns[4].trim())) {
                COL_CHECK_PRICE[4] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[4] + "不能为空!";
            } else {
                GSProviderBean pbean = ppro.queryProviderByShortNameOrId(tRecorderColumns[4].trim());
                if (pbean == null) {
                    COL_CHECK_PRICE[4] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[4] + "不存在或有相同简称供应商!";
                } else {
                    manuview.setGs_provider_id(pbean.getGs_provider_id());
                    manuview.setGs_provider_shortname(pbean.getGs_provider_shortname());
                }             
            }
            if ("".equals(tRecorderColumns[5].trim())) {
                COL_CHECK_PRICE[5] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "不能为空!";
            } else {
                Pattern pattern = Pattern.compile("^[0-9]*\\.?[0-9]{0,4}");
                Matcher isNum = pattern.matcher(tRecorderColumns[5].trim());
                if (!isNum.matches()) {
                    COL_CHECK_PRICE[5] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "必须为数值!";
                } else if (Double.parseDouble(tRecorderColumns[5].trim()) < 0) {
                    COL_CHECK_PRICE[5] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "不能小于0!";
                } else {
                    manuview.setGs_manufacture_unitprice(StringUtils.parseDouble(tRecorderColumns[5].trim()));
                }
            }
            if ("".equals(tRecorderColumns[6].trim())) {
                COL_CHECK_PRICE[6] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "不能为空!";
            } else {
                Pattern pattern = Pattern.compile("^[0-9]*\\.?[0-9]{0,4}");
                Matcher isNum = pattern.matcher(tRecorderColumns[6].trim());
                if (!isNum.matches()) {
                    COL_CHECK_PRICE[6] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[6] + "必须为数值!";
                } else if (Double.parseDouble(tRecorderColumns[6].trim()) <= 0) {
                    COL_CHECK_PRICE[6] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[6] + "不能小于等于0!";
                } else {
                    manuview.setGs_plan_price(tRecorderColumns[6].trim());
                }
            }
            if ("".equals(tRecorderColumns[7].trim())) {
                COL_CHECK_PRICE[7] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[7] + "不能为空!";
            } else {
                manuview.setGs_quant_unit(tRecorderColumns[7].trim());
            }
            if ("1".equals(tRecorderColumns[8].trim()) || "0".equals(tRecorderColumns[8].trim())) {
                manuview.setIs_buy(tRecorderColumns[8].trim());
            } else {
                COL_CHECK_PRICE[8] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[8] + " 错误!，请选择0或1。";
            }
            
            manuview.setGs_manufacture_type(tRecorderColumns[9].trim());
            manuview.setGs_manufacture_spec(tRecorderColumns[10].trim());
            if(!RegulaUtil.matchByString(tRecorderColumns[11],zhibao)){
       		 	COL_CHECK[11] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[11] + "只能为0或者正整数，默认单位为天!";
            }
            manuview.setGs_quality_assure_period(tRecorderColumns[11].trim());
            manuview.setGs_manufacturer_name(tRecorderColumns[12].trim());
            manuview.setGs_make_area(tRecorderColumns[13].trim());
            manuview.setGs_manufacture_brand(tRecorderColumns[14].trim());
            manuview.setGs_drawing_piece_code(tRecorderColumns[15].trim());
            String temp = "";
            if (!"".equals(tRecorderColumns[16].trim())) {
                temp += HEAD_NAMES[16] + "：" + tRecorderColumns[17].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[17].trim())) {
                manuview.setGs_adapt_machine_type(tRecorderColumns[18].trim());
                temp += HEAD_NAMES[17] + "：" + tRecorderColumns[18].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[18].trim())) {
                temp += HEAD_NAMES[18] + "：" + tRecorderColumns[19].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[19].trim())) {
                temp += HEAD_NAMES[19] + "：" + tRecorderColumns[20].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[20].trim())) {
                temp += HEAD_NAMES[20] + "：" + tRecorderColumns[21].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[21].trim())) {
                temp += HEAD_NAMES[21] + "：" + tRecorderColumns[22].trim() + "；";
            }
            manuview.setGs_appender_property(temp);
            manuview.setGs_remark(tRecorderColumns[22].trim());
            manuview.setGs_recorder_id(String.valueOf(a));//对象编号
        } catch (GSException e) {
            e.printStackTrace();
            GSLogWriter.error(e.getMessage());
            throw new GSException("批量导入产品明细失败:" + e.getLocalizedMessage());

        }
        return aRowText + "匹配成功！";
    }
     
    public String checkManufacture(String aRowText,int a) throws Exception {
        manuview = new GSManufactureView();
        for (int i = 0; i < COL_CHECK.length; i++) {
            COL_CHECK[i] = true;
        }
       
        try {
            String[] tRecorderColumns = aRowText.split(SEP);
            for (int i = 0; i < tRecorderColumns.length; i++) {
            	if(!RegulaUtil.matchByString(tRecorderColumns[i],regula)){
            		 COL_CHECK[i] = false;
                     return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[i] + "不能为',\",<,>,&等特殊字符!";
            	}
			}
            manuview.setGs_manufacture_id(tRecorderColumns[0].trim());
            if ("".equals(tRecorderColumns[1].trim())) {
                COL_CHECK[1] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[1] + "不能为空!";
            } else {
                GSManufactureCategoryBean mcbean = mcpro.queryManufactureCatetoryByIdOrName(tRecorderColumns[1].trim());
                if (mcbean == null) {
                    COL_CHECK[1] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[1] + "不存在或有相同类型名称！";
                } else {
                    manuview.setGs_manufacture_category_id(mcbean.getGs_manufacture_category_id());
                    manuview.setGs_manufacture_category_name(mcbean.getGs_manufacture_category_name());
                }
            }
            if ("".equals(tRecorderColumns[2].trim())) {
                COL_CHECK[2] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[2] + "不能为空!";
            } else {
                manuview.setGs_concentricity_id(tRecorderColumns[2].trim());
            }
            if ("".equals(tRecorderColumns[3].trim())) {
                COL_CHECK[3] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[3] + "不能为空!";
            } else {
                manuview.setGs_manufacture_name(tRecorderColumns[3].trim());
            }
            if ("".equals(tRecorderColumns[4].trim())) {
                COL_CHECK[4] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[4] + "不能为空!";
            } else {
                GSProviderBean pbean = ppro.queryProviderByShortNameOrId(tRecorderColumns[4].trim());
                if (pbean == null) {
                    COL_CHECK[4] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[4] + "不存在或有相同简称供应商!";
                } else {
                    manuview.setGs_provider_id(pbean.getGs_provider_id());
                    manuview.setGs_provider_shortname(pbean.getGs_provider_shortname());
                }      
            }
            if ("".equals(tRecorderColumns[5].trim())) {
                COL_CHECK[5] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "不能为空!";
            } else {
                Pattern pattern = Pattern.compile("^[0-9]*\\.?[0-9]{0,4}");
                Matcher isNum = pattern.matcher(tRecorderColumns[5].trim());
                if (!isNum.matches()) {
                    COL_CHECK[5] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "必须为数值!";
                } else if (Double.parseDouble(tRecorderColumns[5].trim()) < 0) {
                    COL_CHECK[5] = false;
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[5] + "不能小于0!";
                } else {
                    manuview.setGs_manufacture_unitprice(StringUtils.parseDouble(tRecorderColumns[5].trim()));
                }
            }
            if ("".equals(tRecorderColumns[6].trim())) {
                COL_CHECK[6] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[6] + "不能为空!";
            } else {
                manuview.setGs_quant_unit(tRecorderColumns[6].trim());
            }
            if ("1".equals(tRecorderColumns[7].trim()) || "0".equals(tRecorderColumns[7].trim())) {
                manuview.setIs_buy(tRecorderColumns[7].trim());
            } else {
               if(!tRecorderColumns[7].trim().equals("")){
                COL_CHECK[7] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[7] + " 错误!，请选择0或1。";
               } 
            }
            if ("1".equals(tRecorderColumns[8].trim()) || "2".equals(tRecorderColumns[8].trim())) {
                manuview.setGs_balance_mode(tRecorderColumns[8].trim());
            } else {
                COL_CHECK[8] = false;
                if(tRecorderColumns[8].trim().equals("")){
                    return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[8] + " 错误!，不能位空。";   
                }else
                   return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[8] + " 错误!，请选择1或2。";
            }
            
            //TODO 9,10
            if(tRecorderColumns[9].trim().equals("")){
            	COL_CHECK[9] = false;
                 return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[9] + " 不能为空!";
            }     
            
            DBConnection con = null;
			try {
				con = DBConnection.open();
	            Conditions condition = new Conditions();
				condition.add(" upper_type = '"+GSBaseConstants.PRODUCT_TYPE_MANAGER_USE+"' ");
				condition.add(" status = 1");
				condition.add(" product_type = '"+tRecorderColumns[9].trim()+"'");
				ObjectList typelist = ProductTypeManager.fetch().search(con,condition);
	            
	            Conditions conditionBid = new Conditions();
				conditionBid.add(" upper_type = '"+GSBaseConstants.PRODUCT_TYPE_MANAGER_BID+"' ");
				conditionBid.add(" status=1");
				conditionBid.add(" product_type = '"+tRecorderColumns[10].trim()+"'");
				ObjectList bIdlist = ProductTypeManager.fetch().search(con,conditionBid);
	            if(!tRecorderColumns[9].trim().equals("")&&typelist.size()<1){
	            	COL_CHECK[9] = false;
	                 return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[9] + " 该产品使用分类不存在!";
	            }
	            if(!tRecorderColumns[10].trim().equals("")&&bIdlist.size()<1){
	            	COL_CHECK[10] = false;
	                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[10] + " 该产品招标分类不存在!";
	           }
			} catch (Exception e) {
				COL_CHECK[10] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": 产品管理分类查询异常!";
			}finally{
				if(con!=null){
					con.close();
				}
			}   
			

            
            manuview.setProduct_type(tRecorderColumns[9].trim());
            manuview.setProduct_bid(tRecorderColumns[10].trim());
            
            manuview.setGs_manufacture_type(tRecorderColumns[11].trim());
            manuview.setGs_manufacture_spec(tRecorderColumns[12].trim());
            if(!RegulaUtil.matchByString(tRecorderColumns[13],zhibao)){
       		 	COL_CHECK[13] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[13] + "只能为0或者正整数，默认单位为天!";
            }
            manuview.setGs_quality_assure_period(tRecorderColumns[13].trim());
            manuview.setGs_manufacturer_name(tRecorderColumns[14].trim());
            manuview.setGs_make_area(tRecorderColumns[15].trim());
            manuview.setGs_manufacture_brand(tRecorderColumns[16].trim());
            manuview.setGs_drawing_piece_code(tRecorderColumns[17].trim());
            String temp = "";
            if (!"".equals(tRecorderColumns[18].trim())) {
                temp += HEAD_NAMES[18] + "：" + tRecorderColumns[18].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[19].trim())) {
                manuview.setGs_adapt_machine_type(tRecorderColumns[19].trim());
                temp += HEAD_NAMES[19] + "：" + tRecorderColumns[19].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[20].trim())) {
                temp += HEAD_NAMES[20] + "：" + tRecorderColumns[20].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[21].trim())) {
                temp += HEAD_NAMES[21] + "：" + tRecorderColumns[21].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[22].trim())) {
                temp += HEAD_NAMES[22] + "：" + tRecorderColumns[22].trim() + "；";
            }
            if (!"".equals(tRecorderColumns[23].trim())) {
                temp += HEAD_NAMES[23] + "：" + tRecorderColumns[23].trim() + "；";
            }
            manuview.setGs_appender_property(temp);
            manuview.setGs_remark(tRecorderColumns[24].trim());
            
            if(!tRecorderColumns[25].trim().equals("")&&!RegulaUtil.matchByString(tRecorderColumns[25].trim(),zhibao)){
       		 	COL_CHECK[25] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[25] + "只能为0或者正整数，默认单位为公里!";
            }
            
//            if(GSBaseConstants.IS_CENTER_WAREHOUSE!=null&&GSBaseConstants.IS_CENTER_WAREHOUSE.equals("true")){
            	  if ("".equals(tRecorderColumns[26].trim())) {
                      COL_CHECK[26] = false;
                      return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[26] + "不能为空!";
                  } else {
                      Pattern pattern = Pattern.compile("^[0-9]*\\.?[0-9]{0,4}");
                      Matcher isNum = pattern.matcher(tRecorderColumns[26].trim());
                      if (!isNum.matches()) {
                          COL_CHECK[26] = false;
                          return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[26] + "必须为数值!";
                      } else if (Double.parseDouble(tRecorderColumns[5].trim()) <0) {
                          COL_CHECK[26] = false;
                          return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[26] + "不能小于0!";
                      } else {
                          manuview.setGs_plan_price(tRecorderColumns[26].trim());
                      }
                  }
 //           }
            
            if ("1".equals(tRecorderColumns[27].trim()) || "0".equals(tRecorderColumns[27].trim())) {
                manuview.setBalance_customer_code(tRecorderColumns[27].trim());
            } else {
               if(!tRecorderColumns[27].trim().equals("")){
                COL_CHECK[27] = false;
                return HEAD_NAMES[0] + tRecorderColumns[0] + ": " + HEAD_NAMES[29] + " 错误!，请选择0或1。";
               } 
            }
            
            manuview.setKm_quality_assure_period(tRecorderColumns[25].trim());
            manuview.setGs_recorder_id(String.valueOf(a));//对象编号
        } catch (GSException e) {
            e.printStackTrace();
            GSLogWriter.error(e.getMessage());
            throw new GSException("批量导入产品明细失败:" + e.getLocalizedMessage());

        }
        return aRowText + "匹配成功！";
    }
}
